package com.tornainbow;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author mrcrysl
 */
public class MockFlow {
    // Define a logger for this class
    private static Logger logger = LoggerFactory.getLogger(MockFlow.class);
    
    public static void main(String[] args) {
        MockFlow test = new MockFlow();
        test.run();
    }
    
    public void run() {
        // Instantiate the first processor
        Processor proc1 = new LocalFileSelector();
        logger.info("Instantiated processor {}", proc1.getProcessorName());
        
        // Instantiate the second processor
        Processor proc2 = new DelimiterParser();
        logger.info("Instantiated processor {}", proc2.getProcessorName());
        
        // Instantiate the third processor
        Processor proc3 = new FlowTerminator();
        logger.info("Instantiated processor {}", proc3.getProcessorName());
        
        // Set the properties for the first processor and start it
        proc1.setProperty(LocalFileSelector.PROP_JMS_SOURCE_QUEUE_NAME, proc1.getProcessorName());
        proc1.setProperty(LocalFileSelector.PROP_JMS_DESTINATION_QUEUE_NAME, proc2.getProcessorName());
        proc1.setProperty(LocalFileSelector.PROP_SOURCE_DIRECTORY, "/home/mcrysler/Desktop/input");
        proc1.setProperty(LocalFileSelector.PROP_KEEP_ORIGINAL, "true");
        proc1.start();
        logger.info("Started processor {}", proc1.getProcessorName());
        
        // Set the properties for the second processor and start it
        proc2.setProperty(DelimiterParser.PROP_JMS_SOURCE_QUEUE_NAME, proc2.getProcessorName());
        proc2.setProperty(DelimiterParser.PROP_JMS_DESTINATION_QUEUE_NAME, proc3.getProcessorName());
        proc2.setProperty(DelimiterParser.PROP_CHARSET, "UTF-8");
        proc2.setProperty(DelimiterParser.PROP_DELIMITER, ",");
        proc2.setProperty(DelimiterParser.PROP_SKIP_NUM_LINES, "0");
        proc2.start();
        logger.info("Started processor {}", proc2.getProcessorName());
        
        // Set the properties for the third processor and start it
        proc3.start();
        proc3.setProperty(FlowTerminator.PROP_JMS_SOURCE_QUEUE_NAME, proc3.getProcessorName());
        logger.info("Started processor {}", proc3.getProcessorName());
    }
}
